<?php
use think\facade\Route;

Route::group('admin', function () {
    Route::post('register', 'login/register');
    Route::post('login', 'login/login');
    Route::get('getCode', 'login/getCode');
    // Route::post('changePwd', 'admin/login/changePwd');
    Route::group('', function () {
        Route::put('user/update', 'user/userUpdate');
        Route::patch('user/changePwd', 'user/changePwd');
        Route::get('getUserInfo/:id', 'user/getUserInfo');
        Route::get('user/hasPermission', 'user/hasPermission');
        Route::get('user/indexRole', 'user/indexRole');
        // RBAC
        // Route::post('roles', 'Role/store');
        // Route::get('roles', 'Role/index');
        // Route::post('roles/attachRole', 'Role/attachRole');
        // Route::get('roles/:id', 'Role/show');
        // Route::put('roles/:id', 'Role/update');
        // Route::delete('roles/:id', 'Role/delete');
        
        // Route::post('permissions', 'Permission/store');
        // Route::get('permissions', 'Permission/index');
        // Route::post('permissions/attachPermission', 'Permission/attachPermission');
        // Route::get('permissions/:id', 'Permission/show');
        // Route::put('permissions/:id', 'Permission/update');
        // Route::delete('permissions/:id', 'Permission/delete');
        Route::get('admin', 'Admin/index');
        Route::post('admin', 'Admin/add');
        Route::put('admin/:id', 'Admin/edit');
        Route::delete('admin/:id', 'Admin/del');
        Route::get('adminInfo/:id', 'Admin/info');
        
        Route::get('menus', 'Menu/index');
        
        // 权限相关
        // 测试
        Route::get('test', 'Role1/test');
        // 角色列表
        Route::get('roleList', 'Role1/rList');
        // 角色详情
        Route::get('roleDetails', 'Role1/details');
        // 角色更新（添加、修改）
        Route::post('roleSave', 'Role1/save');
        // 角色删除
        Route::get('roleDel', 'Role1/delete');
        // 权限列表
        Route::get('permissions', 'Role1/permissions');
        // app权限列表
        Route::get('appPermissions', 'Role1/appPermissions');
        // app获取对应没有的权限列表
        Route::get('appRemovePermissions', 'Role1/appRemovePermissions');
    })->middleware(\app\http\middleware\AuthMiddleware::class);
})->allowCrossDomain()->prefix('admin/');
